package com.hp.bon.sgw.stdbss30;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import com.hp.bon.sgw.stdbss30.common.BizConsts;

public class OutApiCapabilities {

    private static final Map<String, String> capabilities = new HashMap<String, String>();

    static {
        // 对外计费3.0标准接口
        capabilities.put("capabilities.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("QueryBalance.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("BillQueryOwe.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("RealFeeQuery.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("Recharged.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("RechargeRollback.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("RechargeQuery.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("OperSerialQuery.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("PaymentRecordQuery.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("CommonDynQuery.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("ReturnBalance.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("ReturnBalanceDetail.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("BalanceRecord.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("BalanceRecordDetail.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("DayCardUnBlock.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("CreditQuery.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("CreditGive.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("ServAuth.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        capabilities.put("EmergencyBoot.jf3", BizConsts.TYPE_API_CAPABILITY_WS);
        // 对外计费其他接口
        capabilities.put("QueryHomeAreaByAccNbr.HSS", BizConsts.TYPE_API_CAPABILITY_HTTP);
        capabilities.put("QueryServ.HSS", BizConsts.TYPE_API_CAPABILITY_HTTP);
        capabilities.put("CommonDynQuery.HB", BizConsts.TYPE_API_CAPABILITY_HTTP);
        
        // 天卡语音复网 DayCardUnBlock.HB（DayCardUnBlock.WH）
        capabilities.put("DayCardUnBlock.HB", BizConsts.TYPE_API_CAPABILITY_HTTP);
        capabilities.put("DayCardUnBlock.WH", BizConsts.TYPE_API_CAPABILITY_HTTP);
        
        capabilities.put("Query.CreditYXHB9", BizConsts.TYPE_API_CAPABILITY_HTTP);
        capabilities.put("ReturnBalance.balanceYXHB9", BizConsts.TYPE_API_CAPABILITY_HTTP);
        capabilities.put("ReturnBalanceDetail.balanceYXHB9", BizConsts.TYPE_API_CAPABILITY_HTTP);
        capabilities.put("QryBalOwe.Bal", BizConsts.TYPE_API_CAPABILITY_HTTP);
        // 对外查询中心接口
        capabilities.put("BillDetailQuery.BillYXHB9", BizConsts.TYPE_API_CAPABILITY_HTTP);
        // 银行代收费缴费接口
        capabilities.put("NormalPay.Payment", BizConsts.TYPE_API_CAPABILITY_HTTP);
    }


    private static final Set<String> authCcapabilities = new HashSet<String>();

    static {
        // 对外查询中心接口
        authCcapabilities.add("BillDetailQuery.BillYXHB9");
    }

    private static final Set<String> zwFlagCcapabilities = new HashSet<String>();
    private static final Set<String> zwAreaCcapabilities = new HashSet<String>();
    private static final Set<String> zwLatnCcapabilities = new HashSet<String>();

    static {
        // 只用总开关，开关打开则直接调新接口
        zwFlagCcapabilities.add("QueryHomeAreaByAccNbr.HSS");
        zwFlagCcapabilities.add("QueryServ.HSS");
        zwFlagCcapabilities.add("ServAuth.jf3");



        // 需要区域编码 zw_area_code判断
        zwAreaCcapabilities.add("RealFeeQuery.jf3");
        zwAreaCcapabilities.add("RechargeQuery.jf3");
        zwAreaCcapabilities.add("CommonDynQuery.HB");

        /* 天卡语音复网 DayCardUnBlock.HB（DayCardUnBlock.WH）*/
        zwAreaCcapabilities.add("DayCardUnBlock.HB");
        zwAreaCcapabilities.add("DayCardUnBlock.WH");
        
        zwAreaCcapabilities.add("Query.CreditYXHB9");
        zwAreaCcapabilities.add("ReturnBalance.balanceYXHB9");
        zwAreaCcapabilities.add("ReturnBalanceDetail.balanceYXHB9");
        zwAreaCcapabilities.add("QueryBalance.jf3");
        zwAreaCcapabilities.add("BillQueryOwe.jf3");

        zwAreaCcapabilities.add("ReturnBalance.jf3");
        zwAreaCcapabilities.add("ReturnBalanceDetail.jf3");
        zwAreaCcapabilities.add("BalanceRecord.jf3");
        zwAreaCcapabilities.add("BalanceRecordDetail.jf3");
        zwAreaCcapabilities.add("DayCardUnBlock.jf3");
        zwAreaCcapabilities.add("CreditQuery.jf3");
        zwAreaCcapabilities.add("CreditGive.jf3");
        zwAreaCcapabilities.add("EmergencyBoot.jf3");

        zwAreaCcapabilities.add("RechargeRollback.jf3");
        zwAreaCcapabilities.add("OperSerialQuery.jf3");
        zwAreaCcapabilities.add("PaymentRecordQuery.jf3");
        zwAreaCcapabilities.add("CommonDynQuery.jf3");
        zwAreaCcapabilities.add("Recharged.jf3");
        zwAreaCcapabilities.add("QryBalOwe.Bal");


        zwAreaCcapabilities.add("NormalPay.Payment");
        // latnId校检
        zwLatnCcapabilities.add("BillDetailQuery.BillYXHB9");
    }

    public static Set<String> listOutApiCapabilities() {
        return Collections.unmodifiableSet(capabilities.keySet());
    }

    public static boolean hasCapability(String capability) {
        return capabilities.containsKey(capability);
    }

    public static boolean isWSCapability(String capability) {
        if (BizConsts.TYPE_API_CAPABILITY_WS.endsWith(capabilities.get(capability))) {
            return true;
        }
        return false;
    }

    public static boolean isHttpCapability(String capability) {
        if (BizConsts.TYPE_API_CAPABILITY_HTTP.endsWith(capabilities.get(capability))) {
            return true;
        }
        return false;
    }

    public static Set<String> listAuthCapabilities() {
        return Collections.unmodifiableSet(authCcapabilities);
    }

    public static boolean authCapability(String capability) {
        return authCcapabilities.contains(capability);
    }

    public static Set<String> listZwFlagCcapabilities() {
        return Collections.unmodifiableSet(zwFlagCcapabilities);
    }

    public static boolean zwFlagCapability(String capability) {
        return zwFlagCcapabilities.contains(capability);
    }

    public static boolean zwAreaCcapabilities(String capability) {
        return zwAreaCcapabilities.contains(capability);
    }

    public static boolean zwLatnCcapabilities(String capability) {
        return zwLatnCcapabilities.contains(capability);
    }
}
